package com.example.smartcity_40.lawyer;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

import com.example.smartcity_40.R;
import com.example.smartcity_40.lawyer.apter.LawyerBannerApter;
import com.example.smartcity_40.lawyer.apter.LawyerexpertiseApter;
import com.example.smartcity_40.lawyer.bean.LegalexpertiseBean;
import com.example.smartcity_40.tool.Tool;

import kotlin.Unit;
import kotlin.jvm.functions.Function1;

public class LawyerexpertiseActivity extends AppCompatActivity {

    private LawyerexpertiseActivity context;
    private RecyclerView legal_expertise;
    private Tool tool;
    private LawyerexpertiseApter lawyerexpertiseApter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_lawyerexpertise);
        context = this;
        initview();
        legalexpertisemethod();
    }

    private void legalexpertisemethod() {
        tool.send("/prod-api/api/lawyer-consultation/legal-expertise/list",
                Tool.GET,
                null,
                true,
                LegalexpertiseBean.class,
                new Function1<LegalexpertiseBean, Unit>() {
                    @Override
                    public Unit invoke(LegalexpertiseBean legalexpertiseBean) {
                        if (legalexpertiseBean.getCode() == 200) {
                            legal_expertise.setLayoutManager(new GridLayoutManager(context,4,RecyclerView.HORIZONTAL,false));
                            lawyerexpertiseApter.setDate(legalexpertiseBean.getRows());
                            legal_expertise.setAdapter(lawyerexpertiseApter);
                        }
                        return null;
                    }
                });
    }

    private void initview() {
        ImageView back =  findViewById(R.id.back);

        legal_expertise = findViewById(R.id.legal_expertise);
        tool = new Tool(context);
        lawyerexpertiseApter = new LawyerexpertiseApter(context);
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                context.finish();
            }
        });
    }
}